import vue from "@vitejs/plugin-vue";
import vitePluginImp from "vite-plugin-imp";
const { resolve } = require("path");

console.log(resolve(__dirname, "src"));

function pathResolve(dir: string) {
  return resolve(__dirname, ".", dir);
}

/**
 * https://vitejs.dev/config/
 * @type {import('vite').UserConfig}
 */
export default {
  plugins: [
    vue(),
    vitePluginImp({
      libList: [
        {
          libName: "element-plus",
          style: (name: string) => {
            return `element-plus/lib/theme-chalk/${name}.css`;
          },
        },
        // // 完整引入的时候需要注释这块 👇
        // {
        //   libName: "ant-design-vue",
        //   style(name) {
        //     if (/popconfirm/.test(name)) {
        //       return `ant-design-vue/es/popover/style/index.css`;
        //     }
        //     return `ant-design-vue/es/${name}/style/index.css`;
        //   },
        // },
      ],
    }),
  ],
  resolve: {
    alias: [
      {
        find: /^\/@\//,
        replacement: pathResolve("src") + "/",
      },
      // {
      //   "/@/": resolve(__dirname, "src"),
      // },
    ],
  },
  server: {
    proxy: {
      "/api": {
        target: "http://192.168.1.244:3001/",
        changeOrigin: true,
      },
    },
  },
  open: false, // 是否自动在浏览器打开
};
